package com.my.mymafengwo.base;

import android.app.Activity;
import android.os.Bundle;
import android.widget.Toast;

/**
 * ***********************************************
 * author:wgh
 * time:2015/12/1 15:12
 * name:Activity的基类
 * step:
 * ***********************************************
 */
public abstract class BaseActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        loadXml();
        getIntentData(savedInstanceState);
        initViews();
        initData();
        registerListener();
    }

    /**
     * 加载布局文件
     */
    protected abstract void loadXml();

    /**
     * 获取上一个页面的数据
     *
     * @param savedInstanceState
     */
    protected abstract void getIntentData(Bundle savedInstanceState);

    /**
     * 初始化控件
     */
    protected abstract void initViews();

    /**
     * 设置监听器
     */
    protected abstract void registerListener();

    /**
     * 初始化数据
     */
    protected abstract void initData();

    protected void showLongToast(String msg) {
        Toast.makeText(this, msg, Toast.LENGTH_LONG).show();
    }

    protected void showShortToast(String msg) {
        Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
    }
}
